package interchange.domain;

import interchange.data.JDBCServicioDAO;

import java.util.Iterator;
import java.util.List;


public class ServicioStore {

	private static ServicioStore ss;
	private List <Servicio> l;
	
	public static synchronized ServicioStore getInstance() {
        if (ss == null)
            ss = new ServicioStore();
        return ss;
    }
	
	private ServicioStore() {
        l = (new JDBCServicioDAO()).selectAllServicios();
    }
	
	 public List<Servicio> getServicios() {
	        return l;
	    }
	 
	  public Servicio getServicio(String ServicioID) {
	        Servicio result = null;
	        for (Iterator<Servicio> iter = l.iterator(); iter.hasNext();) {
	            Servicio s = (Servicio) iter.next();
	            if (s.getServicioID().compareTo(ServicioID) == 0) {
	                result = s;
	            }
	        }
	        return result;
	    }
}
